﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Quicklight.Web {

   /// <summary>
   /// Event arguments to supply when the ListChanged event of the ObservableList is fired
   /// </summary>
   /// <typeparam name="T">Type of items stored in the ObservableList</typeparam>
   public class ListChangedEventArgs<T> : EventArgs {
      private int insertIndex;
      private List<T> insertList;
      private int removeIndex;
      private List<T> removeList;

      /// <summary>
      /// Constructs a ListChangedEventArgs with the specified inserted and removed items along with the index at which the inserts and removes started
      /// If no items were inserted/added, then the insertList should be empty
      /// If no items were removed, then the removeList should be empty
      /// </summary>
      /// <param name="insertIndex">Index at which inserts, if any, start</param>
      /// <param name="insertList">List of items that were inserted</param>
      /// <param name="removeIndex">Index at which removals, if any, start</param>
      /// <param name="removeList">List of items that were removed</param>
      public ListChangedEventArgs(int insertIndex, List<T> insertList, int removeIndex, List<T> removeList) {
         this.insertIndex = insertIndex;
         this.insertList = insertList;
         this.removeIndex = removeIndex;
         this.removeList = removeList;
      }

      /// <summary>
      /// Index at which inserts, if any, start
      /// </summary>
      public int InsertIndex {
         get { return insertIndex; }
      }

      /// <summary>
      /// List of items that were inserted. If empty, no items were inserted
      /// </summary>
      public List<T> InsertList {
         get { return insertList; }
      }

      /// <summary>
      /// Index at which removals, if any, start
      /// </summary>
      public int RemoveIndex {
         get { return removeIndex; }
      }

      /// <summary>
      /// List of items that were removed. If empty, no items were removed
      /// </summary>
      public List<T> RemoveList {
         get { return removeList; }
      }
   }
}
